package com.tiku.controller;

import com.tiku.common.ResultJson;
import com.tiku.entity.ProductSpecifications;
import com.tiku.service.UserOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 小马不会跑
 * @create 2024-10-06 11:03
 */
@RestController
@RequestMapping("/orders")
@CrossOrigin("*")
public class UserOrderController {
    @Autowired
    private UserOrderService userOrderService;

    /**
     * 订单创建
     * @param selectedSubjects
     * @return
     */
    @PostMapping("/users/order")
    public ResultJson order(@RequestBody List<ProductSpecifications> selectedSubjects){
        // TODO 实现下单逻辑
        return userOrderService.addorder(selectedSubjects);
    }

    /**
     * 订单创建回调
     * @param orderId
     * @return
     */
    @PostMapping("/users/selectOrder")
    public ResultJson createOrder(@RequestBody  String orderId){
        // TODO 实现下单逻辑
        return userOrderService.selectOrder(orderId);
    }

    /**
     * 查询用户所有订单
     * @param orderType
     * @return
     */
    @PostMapping("/users/selectOrders")
    public ResultJson selectOrders(@RequestBody String orderType){
        // TODO 实现下单逻辑
        return userOrderService.selectOrders(orderType);
    }


    @GetMapping("/del/{orderId}")
    public ResultJson delOrder(@PathVariable("orderId") String orderId){
        // TODO 实现删除逻辑
        return userOrderService.delOrder(orderId);
    }


    @PostMapping("/users/activationCode")
    public ResultJson activationCode(String activationCode){
        // TODO 实现下单逻辑
        return userOrderService.activationCode(activationCode);
    }
}
